<script>
  /*
      创建一个Person类，构造方法的参数有名字name和年龄age
      有实例方法 compareAge用来比较年龄
      compareAge返回字符串
    
      如
      ```js
      let p1 = Person("张三", 24)
      let p2 = Person("李四", 36)
      let p3 = Person("王五", 24)
    
      p1.compareAge(p2) // "李四比我大"
      p2.compareAge(p1) // "张三比我小"
      p1.compareAge(p3) // "王五和我一样大"
      ```
    */

  // ？？你的代码
  class Person {
    constructor(name, age) {
      this.name = name;
      this.age = age;
    }
    compareAge(a) {
      if (a.age < this.age) {
        console.log(`${a.name}比我小`);
      } else if (a.age > this.age) {
        console.log(`${a.name}比我大`);
      } else if ((a.age = this.age)) {
        console.log(`${a.name}比我一样大`);
      }
    }
  }
  let p1 = new Person("张三", 24);
  let p2 = new Person("李四", 36);
  let p3 = new Person("王五", 24);

  p1.compareAge(p2); // "李四比我大"
  p2.compareAge(p1); // "张三比我小"
  p1.compareAge(p3); // "王五和我一样大"
</script>
